package dao

import "WORKSPACE/models"

func GetAllgoods() (error, []models.GoodsView, int64) {
	var goodsData []models.GoodsView
	var total int64
	err := db.Table("goodsview").Count(&total).Find(&goodsData).Error
	return err, goodsData, total
}

func Addgoods(goods models.Goods) error {
	err := db.Table("goods").Create(&goods).Error
	return err
}

func Updategoods(goods models.Goods) (error) {
	err := db.Table("goods").Where("goods_id = ?", goods.Goods_id).Updates(&goods).Error
	return err
}

func Delgoods(id int) error {
	err := db.Table("goods").Where("goods_id = ?", id).Delete(models.Goods{}).Error
	return err
}